package com.game.chinesechess.piece.specific;


import com.game.chinesechess.piece.chess;
import com.game.chinesechess.util.Point;

public class elephantChess extends chess {
    public elephantChess(Color color, int x, int y) {
        this.color = color;
        this.point = new Point(x, y);
    }

    @Override
    public Boolean check(chess[][] map, int toX, int toY) {
        int xDistance = Math.abs(this.point.x - toX);
        int yDistance = Math.abs(this.point.y - toY);
        if (!(xDistance == 2 && yDistance == 2))
            return false;
        int block_X = (this.point.x + toX) / 2;
        int block_y = (this.point.y + toY) / 2;
        if (this.color == Color.RED)
            return map[block_X][block_y] == null && toX >= 5;
        else
            return map[block_X][block_y] == null && toX <= 4;
    }

    @Override
    public String getName() {
        return this.color == Color.RED ? "相" : "象";
    }
}
